/*
 * Copyright (C) 2009 M. Hautle.
 * 
 * This file is part of TrackedBean.
 * 
 * TrackedBean is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * TrackedBean is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with TrackedBean. If not, see <http://www.gnu.org/licenses/>.
 */
package ch.trackedbean.copier;

import java.util.*;
import ch.trackedbean.common.*;

/**
 * Interface for mapping engines.<br>
 * The implementation has to be stateless (and thread safe).
 * 
 * @author M. Hautle
 */
public interface IBeanMapper {
	/**
	 * Returns if this mapper does something.
	 * 
	 * @return True if the mapper does something
	 */
	public boolean doesSomething();

	/**
	 * Returns the default base (source) class.
	 * 
	 * @return The base class or null
	 */
	public Class getMappedBaseType();

	/**
	 * Returns the destination type of this mapper.
	 * 
	 * @return The destination type
	 */
	public Class getDstType();

	/**
	 * Copies the values from the src object into the dst object.<br>
	 * 
	 * @param <T> The destination bean type
	 * 
	 * @param src The other object
	 * @param dst The object holding the mapping
	 * @param context The mapping context
	 * @return The filled destination (dst) object
	 * @throws TechnicalException If something goes wrong
	 */
	public <T> T copySrc2Dst(Object src, T dst, IMappingContext context);

	/**
	 * Copies the value from the dst object into the src object.<br>
	 * 
	 * @param <T> The source bean type
	 * 
	 * @param dst The object holding the mapping
	 * @param src The other object
	 * @param context The mapping context
	 * @return The filled source (src) object
	 * @throws TechnicalException If something goes wrong
	 */
	public <T> T copyDst2Src(Object dst, T src, IMappingContext context);

	/**
	 * Returns the mapping holder for the given destination property.
	 * 
	 * @param property The property name
	 * @return The mapping holder or null
	 */
	public IMappingHolder getMappingHolder(String property);

	/**
	 * Returns the all {@link IMappingHolder}s mapped to the source object specified by {@link #getMappedBaseType()} or it's parents (if includeInherited is
	 * set).
	 * 
	 * @param includeInherited True if the inherited mappings should be included
	 * @return The properties
	 */
	public List<IMappingHolder> getMappingHolders(boolean includeInherited);

	/**
	 * Returns the all {@link IMappingHolder}s mapped to the specified class or it's parents (if includeInherited is set).
	 * 
	 * @param baseClass The base class of the source bean
	 * @param includeInherited True if the inherited mappings should be included
	 * @return The properties
	 */
	public List<IMappingHolder> getMappingHolders(Class baseClass, boolean includeInherited);

	/**
	 * Returns the all {@link IMappingHolder}s mapped to the specified class.
	 * 
	 * @param baseClass The base class of the source bean
	 * @return The properties
	 */
	public List<IMappingHolder> getMappingHolders(Class baseClass);
}
